﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Caliburn.Core.Metadata;
using XWord.WPF.ApplicationFramework;
using XWord.Fundamental.Domain;
using System.Threading;
using System.Collections;
using XWord.GUI.Presenters.Interface;
using XWord.Common;
using System.Windows.Documents;
using System.Windows;
using System.Windows.Controls;
using Microsoft.Practices.ServiceLocation;
using System.ComponentModel;
using XWord.WPF.ApplicationFramework.Threads;
using XWord.WPF.ApplicationFramework.Extensions;
using System.Windows.Media;
using XWord.GUI.Presenters.Behaviors;
namespace XWord.GUI.Presenters.Words
{
   

    [Singleton("EtymaWordExplainPresenter", typeof(IWordExplainPresenter))]
    public class EtymaWordExplainPresenter : WordExplainPresenter, IWordExplainPresenter
    {
        public EtymaWordExplainPresenter()
        {
            this.DisplayName = "词根词缀词典";
            this.Index = 1;
            this.BinaryFile =BinaryFiles.EtymaWordExplain;
            CanUpdate = true;
        }


        private EtymaWordBehavior WordBehavior;

        protected override void OnInitialize()
        {
           
            ThreadPool.QueueUserWorkItem(new WaitCallback((object obj) =>
            {
                
                UIThread.BeginInvoke(() =>
                {
                    WordBehavior = new EtymaWordBehavior(WordExplorerPresenter.AdornerElement);
                    
                });
            }));
            base.OnInitialize();
        }

        public IWordExplorerPresenter WordExplorerPresenter { get; set; }

        public override Hashtable TransFormWordToHashtable(Word word)
        {
            var ht = new Hashtable();
            ht["Etyma"] = string.Empty;
            return ht;
        }

        public override void UpdateSelectWord()
        {
            base.UpdateSelectWord();
            if(WordBehavior!=null) WordBehavior.Refresh();
        }

        protected override void OnShutdown()
        {
            base.OnShutdown();
        }
    }
}
